<?php

namespace Admin\Models\statsexplain;

use Phalcon\Db\Column;
use Phalcon\Di;
class ExplainStats extends ServiceDB
{

    public $iESId;            //讲评自增Id
    public $iCreateUserId;    //讲评创建人
    public $iSchoolId;        //学校Id，课件录制学校，4160
    public $iTrId;            //题库Id
    public $iSysTrId;         //数据中心题库Id
    public $iHoId;            //题目Id
    public $iSysHoId;         //数据中心题目Id
    public $iDuration;        //讲评时长
    public $sContent;         //讲评内容
    public $tCreateTime;      //创建时间
    public $tSyncTime;
    public $iDel;             //是否删除
    public $iStatus;          //状态

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        parent::initialize();
        $this->setConnectionService(parent::Service);
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return parent::getTableName('CoursewareStats');
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return Channel[]
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return channel
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }


    /**
     * #方法说明：时间转换
     * @param int $sec
     * @return string
    # Created by zsc
     */
    public static function transform($sec=0){
    //            $output = '';
    //        $hours = floor($sec / 3600);
    //        $remainSeconds = $sec % 3600;
    //        $minutes = floor($remainSeconds / 60);
    //        $seconds = $sec - $hours * 3600 - $minutes * 60;
    //        if($sec >= 3600){
    //            $output .= $hours.'小时';
    //            $output .= $minutes."分";
    //        }
    //        if($sec >= 60 && $sec < 3600){
    //            $output .= $minutes."分";
    //        }
    //        return $output .= $seconds.'秒';
        $minutes = floor($sec/60);
        $seconds = round(($sec % 60),2);
        return sprintf("%.2f", $minutes.'.'.$seconds);
    }
}
